package frame.laxcen.test;

import frame.laxcen.request.Request_0010_0E;
import frame.laxcen.response.Response_0010_0E;
import frame.laxcen.util.FrameUtil;
import tcpclient.v2.RFIDClient;
import frame.util.Ref;

import java.io.IOException;
import java.net.InetSocketAddress;

public class RFIDClient_Get_FreeMode {

    public static void main(String[] args) throws IOException {

        RFIDClient client = new RFIDClient(1 << 20, 1024);

        if(client.tryConnect(new InetSocketAddress("192.168.1.116", 9090))) {

            System.out.println("连接成功！");

            System.out.println("请求读写器空闲模式！");

            if(client.trySend(new Request_0010_0E(), 1000)) {

                System.out.println("请求成功！");

                Ref<Response_0010_0E> response = client.waitForResponse(3000, Response_0010_0E.class);

                if(response.isPresent()) {

                    System.out.println("获取到返回值！");

                    FrameUtil.printResponse(response.get());
                }
            }

            if(client.tryClose()) System.out.println("停止连接！");
        }
    }
}
